import Cookies from 'js-cookie'

const TokenKey = 'token'
const USER_INFO = 'user_info'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// 通过 cookies 操作 userinfo
export function getUserInfo() {
  return JSON.parse(Cookies.get(USER_INFO) || '{}')
}

export function setUserInfo(userInfo) {
  return Cookies.set(USER_INFO, JSON.stringify(userInfo))
}

export function removeUserInfo() {
  return Cookies.remove(USER_INFO)
}

